package com.yuelao.redis;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import redis.clients.jedis.JedisPool;

/**
 * @author FLY
 * @version v1.0
 * @project yuelao-server
 * @date 2017/9/12 10:13
 * @修改记录 版本       修改人         修改时间         修改内容描述
 * --------------------------------------------------
 * <p>
 * --------------------------------------------------
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class Redis {
    @Autowired
    private RedisLock redisLock;

    @Autowired
    private JedisPool jedisPool;

    @Test
    public void getLock() throws InterruptedException {
        long time = System.currentTimeMillis();
        boolean f = redisLock.taskLock("feng", time);
        System.out.println(f);
    }

    @Test
    public void getLock1() {
        long time = System.currentTimeMillis();
        boolean f = redisLock.taskLock("feng", time);
        System.out.println(f);
    }

    @Test
    public void delLock() {
        redisLock.unTaskLock("feng");
    }

    @Test
    public void setKey() {
        jedisPool.getResource().set("fengliye", System.currentTimeMillis() + "");
        System.out.println(jedisPool.getResource().get("fengliye"));
    }
}
